<template>
  <div class="main_box"  style="padding:10px;">
    <div class="detail_wrap">
      <div class="tit">
        <h2>药品信息</h2>
        <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList" > 返 回</el-button>
      </div>
        <div class="con">
            <ul>
              <li>
                <label class="label">药品编号</label>
                <span>{{dataInfo.drugCode}}</span>
              </li>
            </ul>
            <ul>
              <li>
                <label class="label">药品名称</label>
                <span>{{dataInfo.drugName}}</span>
              </li>
            </ul>
            <ul>
              <li>
                <label class="label">药品规格</label>
                <span>{{dataInfo.drugSpecs}}</span>
              </li>
            </ul>
            <ul>
              <li>
                <label class="label">药品单位</label>
                <span>{{dataInfo.drugUnit}}</span>
              </li>
            </ul>
            <ul>
              <li>
                <label class="label">药品价格</label>
                <span>{{dataInfo.drugPrice | PriceUnit }}</span>
              </li>
            </ul>
            <ul>
              <li>
                <label class="label">药品库存</label>
                <span>{{dataInfo.drugInventory}}</span>
              </li>
            </ul>
            <ul>
              <li>
                <label class="label">添加时间</label>
                <span>{{dataInfo.createDate}}</span>
              </li>
            </ul>

          <div class="tit">
            <h2>药厂信息</h2>
          </div>
          <ul>
            <li>
              <label class="label">药厂编号</label>
              <span>{{dataInfo.factoryCode}}</span>
            </li>
          </ul>
          <ul>
            <li>
              <label class="label">药厂名称</label>
              <span>{{dataInfo.factoryName}}</span>
            </li>
          </ul>

        </div>
    </div>
  </div>
</template>

<script>
import ConsumeApi from "@/api/consume/consume";
export default {
  data () {
    return {
      dataInfo: ""
    };
  },
  mounted() {
    this.getData();
  },
  filters: {
    PriceUnit(value) {
      // 价格单位过滤器
      if(value != ""){
        return value + "元";
      } else if(value == ''){
        return " ";
      }
    }
  },
  methods: {
    getData() {
      // 发送请求
      ConsumeApi.getDrugInfo({
        drugId: this.$route.query.id
      }).then(res => {
        this.dataInfo = res.data
      });
    },
    returnList() {
      // 返回
      this.$store.dispatch('delView', this.$route);
      this.$router.push({ path: '/consume/drugManagement'});
    },
  }
}
</script>

<style lang="scss" src="@/assets/css/views/Detail.scss" scope>
</style>
